package com.waves.chat.controller;


import com.waves.chat.domain.dto.chat.ContactFriendDTO;
import com.waves.chat.domain.vo.ChatRoomVO;
import com.waves.chat.service.RoomAppService;
import com.waves.common.domain.vo.IdReqVO;
import com.waves.core.utils.LoginUtils;
import com.waves.core.web.domain.R;
import com.waves.core.web.domain.dto.CursorPageBaseDTO;
import com.waves.core.web.domain.vo.CursorPageBaseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 会话相关接口
 * </p>
 *
 * @author dlw
 * @since 2024-03-19
 */
@RestController
@RequestMapping("/userApi/chat")
@Api(tags = "会话相关接口")
@Slf4j
public class ContactController {
    @Resource
    private RoomAppService roomService;

    @GetMapping("/public/contact/page")
    @ApiOperation("会话列表")
    public R<CursorPageBaseVO<ChatRoomVO>> getRoomPage(@Valid CursorPageBaseDTO dto) {
        return R.ok(roomService.getContactPage(dto));
    }

    @GetMapping("/public/contact/detail")
    @ApiOperation("会话详情")
    public R<ChatRoomVO> getContactDetail(@Valid IdReqVO dto) {
        return R.ok(roomService.getContactDetail(dto.getId()));
    }

    @GetMapping("/public/contact/detail/friend")
    @ApiOperation("会话详情(联系人列表发消息用)")
    public R<ChatRoomVO> getContactDetailByFriend(@Valid ContactFriendDTO dto) {
        return R.ok(roomService.getContactDetailByFriend(dto.getUid()));
    }
}

